package impl.sort;

import anaydis.sort.SorterType;
import anaydis.sort.gui.SorterListener;

import java.util.Comparator;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: Tomi
 * Date: 07/09/2011
 * Time: 13:32:01
 * To change this template use File | Settings | File Templates.
 */
public class ShellSorter extends AbstractSorter {
    private int[] secuencia;
    private SorterListener sorterListener;
    public ShellSorter() {
        super(SorterType.SHELL);
    }
    public ShellSorter(int[] secuencia) {
        super(SorterType.SHELL);
        this.secuencia = secuencia;
    }
    public void add(SorterListener sorterListener) {
        this.sorterListener = sorterListener;
    }
    protected ShellSorter(final SorterType type) {
        super(type);
    }
    public <T> void sort(Comparator<T> c, List<T> list) {
        HSorter hSorter = new HSorter();
        hSorter.addSorterListener(sorterListener);
        for(int i=secuencia.length-1; i>=0; i--){
            hSorter.sort(c, list, secuencia[i]);
        }
    }
}